public class test {
    public static void main(String[] args) {
        int[] nums = {2,3,1,2,4,3};
        int k = minSubArrayLen(7,nums);
        System.out.println(k);
    }


    public static int minSubArrayLen(int target, int[] nums) {
        int head = 0;
        int sign = 0;
        int sum = 0;
        int min = nums.length;
        for(int i = 0; i<nums.length; i++){
            sum += nums[i];
            while(sum >= target){
                sum -= nums[head];
                min = Math.min(min, i-head);
                head += 1;
                sign = 1;
            }
        }
        if(sign == 1){
            min++;
        }else{
            min = 0;
        }
        return min;
    }



}
